import request from '@/utils/request'

const userApi = {
  Login: '/t1/auth/login',
  Logout: '/t1/auth/log_out',
  ResetPassword: '/t1/auth/reset_password',
  CheckPasswordStrength: '/t1/auth/check_password_strength',
  getCode: 't1/auth/get_code'
}

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
// 登录
export function login (parameter) {
  return request({
    url: userApi.Login,
    method: 'post',
    data: parameter
  })
}
// 修改密码
export function ResetPassword (parameter) {
  return request({
    url: userApi.ResetPassword,
    method: 'post',
    data: parameter
  })
}
// 校验密码安全等级
export function CheckPasswordStrength (parameter) {
  return request({
    url: userApi.CheckPasswordStrength,
    method: 'get',
    params: parameter
  })
}
// 登出
export function logout () {
  return request({
    url: userApi.Logout,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 获取验证码
export function getCode (parameter) {
  return request({
    url: userApi.getCode,
    method: 'get',
    params: parameter
  })
}
